package com.example.knowledge.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.knowledge.bean.CourseCatalogueBean;
import com.example.news.R;

import java.util.List;

/**
 * 课程目录adapter
 */
public class CourseCatalogueAdapter extends BaseQuickAdapter<CourseCatalogueBean, BaseViewHolder> {
    public CourseCatalogueAdapter(int layoutResId, @Nullable List<CourseCatalogueBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, CourseCatalogueBean item) {
        helper.setText(R.id.tv_num, item.getNum());
        helper.setText(R.id.tv_title, item.getTitle());
        RelativeLayout rl_audition = helper.getView(R.id.rl_audition);
        ImageView iv_play = helper.getView(R.id.iv_play);
        ImageView iv_lock = helper.getView(R.id.iv_lock);
        if (0 == item.getState()) {
            rl_audition.setVisibility(View.VISIBLE);
            iv_play.setVisibility(View.VISIBLE);
            iv_lock.setVisibility(View.GONE);
        } else {
            rl_audition.setVisibility(View.GONE);
            iv_play.setVisibility(View.GONE);
            iv_lock.setVisibility(View.VISIBLE);
        }
    }
}
